package com.person.leetcode.editor.cn;

import java.net.BindException;

/**
  * 1252.奇数值单元格的数目
  * 2022-07-12 11:02:38
**/
public class Sequence_1252_CellsWithOddValuesInAMatrix {
    public static void main(String[] args) {
        Solution solution = new Sequence_1252_CellsWithOddValuesInAMatrix().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int oddCells(int m, int n, int[][] indices) {
        int[][] arr = new int[m][n];
        for (int i = 0; i <indices.length; i++) {
                arr[indices[i][0]][indices[i][1]]++;
        }
        int[] mArr = new int[m];
        int[] nArr = new int[n];
        for (int i = 0; i < m; i++) {
            int sum = 0;
            for (int j = 0; j < n; j++) {
                sum += arr[i][j];
            }
            mArr[i] = sum;
        }
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += arr[j][i];
            }
            nArr[i] = sum;
        }
        int res =0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if ((mArr[i]+nArr[j])%2 == 1){
                    res ++;
                }
            }
        }
        return res;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}